package com.myapp.ruyixing.http;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import com.myapp.ruyixing.model.ActivityOrderList;

public class ActivityOrderListParser extends RYJSONParser {
	@Override
	public Object parse(JSONObject jsonObject) {
		ActivityOrderList orderList = new ActivityOrderList();

		ListModelParser.parseListModel(orderList, jsonObject);
		JSONObject data = jsonObject.optJSONObject("data");
		JSONArray array = data.optJSONArray("items");
		orderList.items = new ArrayList<ActivityOrderList.Order>();
		for (int i = 0; array != null && i < array.length(); i++) {
			JSONObject object = array.optJSONObject(i);
			if (object != null) {
				ActivityOrderList.Order order = new ActivityOrderList.Order();
				order.datetime = object.optString("datetime", "");
				order.dataid = object.optString("dataid", "");
				order.name = object.optString("name", "");
				order.phone = object.optString("phone", "");
				orderList.items.add(order);
			}
		}

		return orderList;

	}
}
